<?php
include_once("includes/global.php");
include_once("includes/smarty_config.php");
if($config['temp']=='wap')
{
	$id=$_GET['id']?$_GET['id']*1:"0";
	$type=$_GET['type']?$_GET['type']*1:"0";
	if(!empty($id) and is_numeric($id))
	{
		$sql="select con_desc,template,con_title,title,keywords,description,msg_online from ".WEBCON." WHERE  con_id='$id'";
		$db->query($sql);
		$de=$db->fetchRow();
	}
	else if(!empty($type) and is_numeric($type))
	{
		$sql="select con_id as id,con_title as title from ".WEBCON." where con_statu=1 and type='1' and con_group='$type' and lang='$config[language]' order by con_no asc";
		$db->query($sql);
		$de = $db->getRows();
	}
	else
	{
		$sql="select * from ".WEBCONGROUP." where lang='$config[language]'";
		$db->query($sql);
		$de = $db->getRows();
	}
    $tpl->assign("de",$de);
	$tpl->assign("config",$config);
	$page='help.htm';
}
else
{
	$group_id = intval($_GET['cron_group']) ? intval($_GET['cron_group']) : 0 ;
$sql="select * from ".WEBCONGROUP." where lang='$config[language]'";
$db->query($sql);
$con_groups = $db->getRows();
$tpl->assign("con_groups",$con_groups);
	$current_group = !empty($group_id) ? $group_id : reset(array_column($con_groups,'id'));


//==================================================
	$con_sql = "select * from ".WEBCON." where con_statu = 1 and con_group = '$current_group' and lang = '$config[language]'  ";
	$db->query($con_sql);
	$con_group = $db->getRows();
	$tpl->assign('con_group',$con_group);

	//======================================================================
    $help_sql = "select * from ".WEBCONGROUP. " where id = '$current_group' and lang = '$config[language]'  ";
	$db->query($help_sql);
	$de = $db->fetchRow();

	//===============================================================
	$action = $_GET['action'];
	if($action == 'detail'){
		$con_id = $_GET['con_id']*1;
		$db->query("select * from ".WEBCON." where con_id = '$con_id' ");
		$info = $db->fetchRow();
		$tpl->assign('info',$info);

		$current_group = $info['con_group'];
		$config['title']=$info['title'];
		$config['keyword']=$info['keywords'];
		$config['keywords']=$info['keywords'];

	} else {
		$tpl->assign('de',$de);
		$config['title']=$de['title'];
		$config['keyword']=$de['title'];
		$config['description']=$de['title'];
	}



	$tpl->assign('current_group',$current_group);
//======================================================================
include_once("footer.php");

if(!empty($de['template'])&&file_exists($tpl->template_dir.'/'.$de['template']))
	$page=$de['template'];
else
	if($action == 'detail'){
		$page='help_detail.htm';
	} else {
		$page='help.htm';
	}

}

$tpl->display($page);
?>